/**
 * Copyright (C) 2017 - 2020 https://github.com/joewee
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bifrost.game.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 抽奖游戏奖品
 *
 * @author joewee
 * @version 1.0.0
 * @Date 2018/5/8 11:54
 */
@Entity
@Table(name = "LOTTERY_GAME_AWARD",indexes = {
        @Index(name = "GAME_AWARD_INDEX",columnList = "GAME_ID,AWARD_ID",unique = true)
})
public class LotteryGameAward implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    /**
     * 奖品id
     */
    @JoinColumn(name = "AWARD_ID",nullable = false)
    @ManyToOne(fetch = FetchType.LAZY)
    @JsonBackReference
    private LotteryAward lotteryAward;

    /**
     * 游戏id
     */
    @JoinColumn(name = "GAME_ID",nullable = false)
    @ManyToOne(fetch = FetchType.LAZY)
    @JsonBackReference
    private LotteryGame lotteryGame;
    /**
     * 等级
     */
    @Column(name = "GRADE",length = 64,nullable = false)
    private String grade;
    /**
     * 奖品数量
     */
    @Column(name ="QUANTITY",nullable = false)
    private Integer quantity = 0;
    /**
     * 可用数量
     */
    @Column(name ="QUANTITY_AVAILABLE",nullable = false)
    private Integer quantityAvailable = quantity;
    /**
     * 最多多少次领完奖品
     */
    @Column(name ="MAX_TIMES",nullable = false)
    private Integer maxTimes;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public LotteryAward getLotteryAward() {
        return lotteryAward;
    }

    public void setLotteryAward(LotteryAward lotteryAward) {
        this.lotteryAward = lotteryAward;
    }

    public LotteryGame getLotteryGame() {
        return lotteryGame;
    }

    public void setLotteryGame(LotteryGame lotteryGame) {
        this.lotteryGame = lotteryGame;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Integer getQuantityAvailable() {
        return quantityAvailable;
    }

    public void setQuantityAvailable(Integer quantityAvailable) {
        this.quantityAvailable = quantityAvailable;
    }

    public Integer getMaxTimes() {
        return maxTimes;
    }

    public void setMaxTimes(Integer maxTimes) {
        this.maxTimes = maxTimes;
    }
}
